x509attr: check for errors of sk_ASN1_TYPE_push() & use reserve call#1034
x509attr: check for errors of sk_ASN1_TYPE_push() & use reserve call#1034rhenium merged 2 commits intoruby:masterfrom
Conversation
This function returns 0 on error.
| GetX509Attr(self, attr); | ||
| count = X509_ATTRIBUTE_count(attr); | ||
| /* there is no X509_ATTRIBUTE_get0_set() :( */ | ||
| #if OSSL_OPENSSL_PREREQ(3, 0, 0) |
There was a problem hiding this comment.
Could you check the availability of the function in ext/openssl/extconf.rb instead?
There was a problem hiding this comment.
I'll do that after lunch. THanks, I'm relatively new to Ruby extension development so wasn't familiar with this.
This should avoid reallocations and prevent the main error condition of the push call.
|
It doesn't really matter here since we know I repeat what I mentioned elsewhere: I really wish @ndossche would stop pushing the use of |
|
@botovq jeez, I pushed for the use of reserve like twice or so. I agree you need the push check but I disagree with your opinion about it being an unnecessary API. I'll stop pushing reserve if that makes you happy and if that means you leave me alone rather than apparently follow me around on github. |
|
@ndossche Yes, two of the three uses I know outside of OpenSSL itself... Just to be clear: I do not follow you around specifically and I think the work prompted by your static analyzer is really great. What I do is I look at downstream changes and point out things that aren't done ideally. But yes, if you stop using the reserve API this will decrease the likelihood of me complaining. |
See individual commits.
This function returns 0 on error. The main error condition is reallocation, so use a reserve call to avoid reallocations as well.
This was found by a hybrid static-dynamic analyser that looks for inconsistent handling of error checks in bindings.